package com.example.demo.controller;

import com.example.demo.base.*;
import com.example.demo.entity.HouseInfo;
import com.example.demo.service.DeviceService;
import com.example.demo.service.HouseInfoService;
import com.example.demo.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Validated
@RequestMapping({"/manage/"})
public class DeviceController {

    @Autowired
    private DeviceService deviceService;


    @RequestMapping(value = "/device/list")
    public BaseResponse getUserList(
            @RequestParam(required = false, value = "page") Integer pageNo,
            @RequestParam(required = false, value = "rows") Integer pageSize,
            HttpServletRequest request) {

        QueryBuilder queryBuilder = new QueryBuilder();

        Pageable pageable = deviceService.selectEntitiesByPage(queryBuilder,pageNo,pageSize);

        BaseResponse response = new BaseResponse();
        response.setRows(pageable.getRecords());
        response.setTotal(new Long(pageable.getTotal()).intValue());

        return response;
    }

}
